/**
 * Created by taohj on 2014/4/21.
 */



var functionMenu = null;

var functions = new util.Map();

var main = null;





function init() {




    functionMenu =$("#functionMenu");
    main = $("#main");
    main.html("<div></div>");
    main = main.find("div");


    //显示标签页
    main.tabs({
        fit: true,
        border:false,
        plain:true
    });




    /*
     * 构建功能菜单
     * */
    functionMenu.tree({
            url: '/admin/getFunctionMenuTree',
        method: 'post',
        formatter:function(node){
            return node.text;
        },
        onClick: function (node) {
           if (node.url && node.url.length>0) {

                if (!main.tabs('exists', node.text)) {
                    main.tabs('add', {
                        title: node.text,
                        href: node.url,
                        closable: true,
                        fit: true
                    });
                } else {
                    main.tabs('select', node.text);
                }

            }

        }
    });


    /*initFuntions();*/
   loadJss();


}


function loadJss() {
    var path = "/resources/js/opendata/admin/";

    util.loaddJS(path + "dataset.js");
    util.loaddJS(path + "dictionary.js");
    util.loaddJS(path + "org.js");
    util.loaddJS(path + "data.js");
    util.loaddJS(path + "datatheme.js");
    util.loaddJS(path + "app.js");
    util.loaddJS(path + "apptheme.js");
    util.loaddJS(path + "model.js");
    util.loaddJS(path + "user.js");
    util.loaddJS(path + "sysRole.js");
    util.loaddJS(path + "sysAdmin.js");




}



/*
* 获得功能权限
* */
function initFuntions() {




    $.post('getFunctinMenu', {}, function (result) {
        var data = $.parseJSON(result);

        functions=new util.Map();
        for (var i = 0; i < data.length; i++) {
            var o = data[i];
            o.toString=function(){
                return this.url;
            }
            functions.put(o.text, o)
        }
    });

}

$(init);


